import pymysql

con = pymysql.connect(host="localhost",user="root",password="123456",database="spider")
# 获取游标
cursor = con.cursor()
# sql
sql = """
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
age INT
)
"""
# 执行sql
cursor.execute(sql)
# 需要提交
con.commit()